#!/usr/bin/env python
# -*- coding:utf-8 -*-
import re


print('' + ' -----------------------------------------------------------------------------------------------------------------------')
# 替换
pattern = re.compile(r'(\w+) (\w+)')
str = 'hello 123 hello 456'
m = pattern.sub("hello world", str)
n = pattern.sub(r'\2 \1', str)
print(m)  # hello world hello world
print(n)  # 123 hello 456 hello



